package com.linxz.wandnroid.presenter;

import com.linxz.framework.base.ActivityLifeCycleEvent;
import com.linxz.framework.base.presenter.BasePresenter;
import com.linxz.framework.protocol.callback.ModelCallBack;
import com.linxz.wandnroid.appui.view.ProjectFragView;
import com.linxz.wandnroid.module.WanAndroidModule;
import com.linxz.wandnroid.pojo.Category;

import java.util.List;

import io.reactivex.subjects.PublishSubject;

/**
 * @author Linxz
 * 创建日期：2020年02月29日 10:13
 * version：v4.5.4
 * 描述：
 */
public class ProjectFragPresenter extends BasePresenter<ProjectFragView, WanAndroidModule> {

    public ProjectFragPresenter(ProjectFragView mView, PublishSubject<ActivityLifeCycleEvent> lifecycleSubject) {
        super(mView, lifecycleSubject);
    }

    @Override
    public WanAndroidModule createModel(PublishSubject<ActivityLifeCycleEvent> lifecycleSubject) {
        return new WanAndroidModule(lifecycleSubject);
    }

    public void getCategory(){
        mModel.getProjectCategory(new ModelCallBack<List<Category>>() {
            @Override
            public void onSuccess(List<Category> model) {
                if (model==null || model.size()==0){
                   mView.onLoadEmpty();
                }else{
                    mView.onLoadSuccess(model);
                }
            }

            @Override
            public void onErrors(String code, String msg) {
                mView.onLoadError(msg);
            }
        });
    }
}
